<?php

class PreparaUtf {

    function prepara($array) {
        if (is_array($array)) {
            $array1 = array();
            foreach ($array as $key => $value) {
                if (is_array($value)) {
                    $array1[$key] = $this->prepara($value);
                } else {
                    $array1[$key] = mb_convert_encoding($value, 'utf-8', 'iso-8859-1');
                }
            }
        } else {
            $array1 = mb_convert_encoding($array, 'utf-8', 'iso-8859-1');
        }
        return $array1;
    }

    function prepara_decode($array) {
        $array1 = array();
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $array1[$key] = $this->prepara_decode($value);
            } else {
                $array1[$key] = mb_convert_encoding($value, 'iso-8859-1', 'utf-8');
            }
        }
        return $array1;
    }

    function remove_slashes($array) {
        $array1 = array();
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $array1[$key] = $this->remove_slashes($value);
            } else {
                $array1[$key] = stripcslashes($value);
            }
        }
        return $array1;
    }
}

?>